@include('admin.public.head')
<link href="{{ URL::asset('./admin/css/main.css') }}" rel="stylesheet">
<style>
    * {
        -webkit-box-sizing: initial;
        box-sizing: initial;
    }

    .wrapper h2 {
        height: 35px;
        line-height: 35px;
        font-size: 15px;
        border-bottom: 1px solid #e7eaec;
    }
</style>
<body class="gray-bg">
<form method="post" enctype="multipart/form-data" id="brandForm">
    <section class="page wrapper wrapper-content animated fadeInRight">
        <h2><strong>管理员编辑</strong></h2>
        <ul class="ulColumn2">
            <li>
                <span class="item_name" style="width:120px;">管理员账号：</span>
                <input type="text" class="textbox textbox_295" name="account" id="account" placeholder="管理员账号..."/>
            </li>
            <li>
                <span class="item_name" style="width:120px;">管理员角色：</span>
                <select name="role_id" id="" class="textbox textbox_295">
                    @foreach ($list as $vo)
                        <option value="{{$vo->role_id}}">{{$vo->role_name}}</option>
                    @endforeach
                </select>
            </li>
            <li>
                <span class="item_name" style="width:120px;">管理员密码：</span>
                <input type="password" class="textbox textbox_295" name="pwd" id="passwd" placeholder="管理员密码..."/>
            </li>
            <li>
                <span class="item_name" style="width:120px;">确认密码：</span>
                <input type="password" class="textbox textbox_295" name="repasswd" id="repasswd" placeholder="确认密码..."/>
            </li>
            <li>
                <span class="item_name" style="width:120px;">真实姓名：</span>
                <input type="text" class="textbox textbox_295" name="real_name" id="real_name" placeholder="真实姓名..."/>
            </li>
            <li>
                <span class="item_name" style="width:120px;"></span>
                <input type="button" class="link_btn" value="提交"/>
            </li>
        </ul>
    </section>
</form>
<!--tabStyle-->
<script type="text/javascript">
    $(document).ready(function () {
        //tab
        $(".admin_tab li a").click(function () {
            var liindex = $(".admin_tab li a").index(this);
            $(this).addClass("active").parent().siblings().find("a").removeClass("active");
            $(".admin_tab_cont").eq(liindex).fadeIn(150).siblings(".admin_tab_cont").hide();
        });

        $(".link_btn").click(function () {

            if ($("#account").val() == "") {
                alert("管理员账号不能为空!");
                return false;
            }

            if ($("#passwd").val() == "") {
                alert("管理员密码不能为空!");
                return false;
            }

            if ($("#passwd").val() != $("#repasswd").val()) {
                alert("两次密码不一样!");
                return false;
            }

            if ($("#real_name").val() == "") {
                alert("真实姓名不能为空!");
                return false;
            }

            var form = $("#brandForm").serialize();

            $.ajax({
                url: "/edit_do",    //请求的url地址
                dataType: "json",   //返回格式为json
                data: form,
                type: "POST",   //请求方式
                success: function (req) {
                    //请求成功时处理
                    if (req.status == 0) {
                        layer.msg(req.message);
                        return false;
                    }


                    layer.msg('操作成功！');
                    setTimeout(function () {
                        window.location.href = "/admin_li";
                    }, 500);
                }
            });

            return false;


        });

    });
</script>


</div>
</section>
</body>
</html>
